<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script type='text/javascript' src='libs/createjs.min.js'></script>
    <script src="./js/component.js"></script>
    <script src="./js/view.js"></script>
    <script src="./js/module.js"></script>
    <script src="./js/ascainiao.js"></script>
    <script src="./js/event.js"></script>
    <script src="./js/drag_helper.js"></script>
    <script src="money.js"></script>
    <script src="libs/Vector.js"></script>
    <script>
        function init(){
            const cjs=createjs;
            const comp=AdobeAn.getComposition("24CFEE07DB89A1409F4099D92BC2CACD");
            AdobeAn.lib=comp.getLibrary();
            AdobeAn.comp=comp;
            const {GameControl,PreloadModule,DragHelper}=AdobeAn;
            //console.log(ASCaiNiao);
            let canvas=document.getElementById('canvas');
            const stage=new cjs.Stage(canvas);
            stage.enableMouseOver();
            const exportRoot=new cjs.Container;
            stage.addChild(exportRoot);
            DragHelper.init(stage);
            //程序入口
            GameControl.init(exportRoot,[PreloadModule]);
            cjs.Ticker.framerate=60;
            cjs.Ticker.addEventListener("tick", function(){
                stage.update();
            });
            window.addEventListener('resize', resizeCanvas);
            //console.log(window.screen);
        }
        //进行全屏并适配各浏览器
function fullScreen(canvas) {
	//console.log(666)
    let element = canvas,
		method = "RequestFullScreen";
	//var element = document.getElementById('div'),
	let prefixMethod;
	["webkit", "moz", "ms", "o", ""].forEach(function (prefix) {
		if (prefixMethod)
			return;
		if (prefix === "") {
			// 无前缀，方法首字母小写
			method = method.slice(0, 1).toLowerCase() + method.slice(1);
		}
		var fsMethod = typeof element[prefix + method];
		if (fsMethod + "" !== "undefined") {
			// 如果是函数,则执行该函数
			if (fsMethod === "function") {
				prefixMethod = element[prefix + method]();
			} else {
				prefixMethod = element[prefix + method];
			}
		}
	});
	return prefixMethod;
}
//推出全屏
function exitFullScreen() {
	try {
		de = document;
		// exit full-screen
		if (de.exitFullscreen) {
			de.exitFullscreen();
		} else if (de.webkitExitFullScreen) {
			de.webkitExitFullScreen();
		} else if (de.webkitCancelFullScreen) {
			de.webkitCancelFullScreen();
		} else if (de.mozCancelFullScreen) {
			de.mozCancelFullScreen();
		} else if (de.msExitFullScreen) {
			de.msExitFullScreen();
		}
        //console.log('退出全屏');
	} catch (err) {
		alert(err.description);
	}
}
function resizeCanvas() {
    const cjs=createjs;
    const {MessageControl,ModuleEvent}=AdobeAn;
    
    //console.log(screen.availHeight,screen.height);
    if(screen.availHeight==screen.height){
        canvas.width = canvas.clientWidth;
	    canvas.height = canvas.clientHeight;
        //发送全屏事件
        let evt=new cjs.Event(ModuleEvent.FULL_SCREEN);
        evt.data={width:canvas.clientWidth,height:canvas.clientHeight};
        MessageControl.send(evt);
    }else if(screen.height>screen.availHeight){
        canvas.width = AdobeAn.lib.properties.width;
	    canvas.height = AdobeAn.lib.properties.height;
        //发送退出全屏事件
        let evt=new cjs.Event(ModuleEvent.OUT_FULL_SCREEN);
        evt.data={width:AdobeAn.lib.properties.width,height:AdobeAn.lib.properties.height};
        MessageControl.send(evt);
    }
}
    </script>
</head>
<body>
    <body onload="init();" style="margin:0px;text-align: center;">
        <canvas id="canvas" width="800" height="600"></canvas>
    </body>
</body>
</html>